package com.salton123.charging.util;

import com.salton123.charging.Consts;

import java.util.Calendar;

public class TimeUtils {
    public static int getHour(String str) {
        try {
            return Integer.parseInt(str.split(":")[0]);
        } catch (Exception unused) {
            return 0;
        }
    }

    public static int getMinute(String str) {
        try {
            return Integer.parseInt(str.split(":")[1]);
        } catch (Exception unused) {
            return 0;
        }
    }

    public static boolean compareTime(String str, String str2, String str3) {
        boolean z = true;
        if (str2.equals(str3)) {
            return true;
        }
        Calendar instance = Calendar.getInstance();
        Calendar instance2 = Calendar.getInstance();
        Calendar instance3 = Calendar.getInstance();
        instance.set(11, getHour(str));
        instance.set(12, getMinute(str));
        instance2.set(11, getHour(str2));
        instance2.set(12, getMinute(str2));
        instance3.set(11, getHour(str3));
        instance3.set(12, getMinute(str3));
        str = Consts.CUSTOM_TIME_DEFAULT;
        if (str.equals(str3)) {
            instance3.add(5, 1);
        }
        if (str.equals(str2)) {
            instance2.add(5, -1);
        }
        instance.add(13, 1);
        if (!(instance.after(instance2) && instance.before(instance3))) {
            z = false;
        }
        return z;
    }
}
